package com.sgb.kjwl.view.ui.fragment.demandHall;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ColorUtils;
import com.sgb.alimaplibrary.SelectAddressActivity;
import com.sgb.goods.entity.GoodsItemEntity;
import com.sgb.goods.view.activity.inquiry.InquiryPublishingActivity;
import com.sgb.goods.view.activity.inquiry.NewPurchasesActivity;
import com.sgb.jicai.view.activity.FactoryCentralizedActivity;
import com.sgb.jicai.view.activity.JcMyPriceActivity;
import com.sgb.jicai.view.activity.JiCaiDaTingActivity;
import com.sgb.jicai.view.activity.MyCenterMyJoinActivity;
import com.sgb.jicai.view.activity.XuFangFaQiActivity;
import com.sgb.kjwl.AppFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FragmentDemandhallList2Binding;
import com.sgb.kjwl.di.home.DaggerHomeFragComponent;
import com.sgb.kjwl.di.home.HomeFragModule;
import com.sgb.kjwl.model.entity.DemandHallListEntity;
import com.sgb.kjwl.model.entity.EnquiryTypeEntity;
import com.sgb.kjwl.model.entity.HomeMenuEntity;
import com.sgb.kjwl.model.entity.home.UpdateIndexEvent;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.NumberConstant;
import com.sgb.kjwl.view.event.CategoryEvent2;
import com.sgb.kjwl.view.event.LoginEvent;
import com.sgb.kjwl.view.ui.activity.enterprise.MakeOverActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.NeedActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalQuoteActivity;
import com.sgb.kjwl.view.ui.activity.enterprise.ProfessionalTeamChangeActivity;
import com.sgb.kjwl.view.ui.activity.lease.LeaseHallActivity2;
import com.sgb.kjwl.view.ui.activity.manage.CompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.EpAssestActivity;
import com.sgb.kjwl.view.ui.activity.manage.IPActivity;
import com.sgb.kjwl.view.ui.activity.manage.ManageActivity;
import com.sgb.kjwl.view.ui.activity.manage.SpecialQualificationActivity;
import com.sgb.kjwl.view.ui.activity.manage.TradeHonorActivity;
import com.sgb.kjwl.view.ui.activity.material.GoodsAggregateActivity;
import com.sgb.kjwl.view.ui.activity.packers.FindPackersActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEmploymentActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEngineeringCompanyActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersFindPeopleActivity;
import com.sgb.kjwl.view.ui.activity.packers.ServicesCompanyActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickBiddingListActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickHallActivity3;
import com.sgb.kjwl.view.ui.activity.pick.PickListActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickNoticeActivity;
import com.sgb.kjwl.view.ui.activity.pick.PickWinningNoticeActivity;
import com.sgb.kjwl.view.ui.activity.quotedprice.QuotedPriceActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.activity.transport.BiddingTransportHallActivity;
import com.sgb.kjwl.view.ui.activity.transport.DriverLookForGoodsActivity;
import com.sgb.kjwl.view.ui.activity.transport.GoodsCarsActivity;
import com.sgb.kjwl.view.ui.adapter.carrierDemand.DemandHallAdapter;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryClickListener;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryEntity;
import com.sgb.kjwl.view.ui.quickentry.QuickEntryPopWindow;
import com.sgb.kjwl.view.widget.Enquirytypepopwindow;
import com.sgb.kjwl.viewmodel.demand.DemandHallTabModel2;
import com.sgb.link.event.LeaseEvent;
import com.sgb.link.router.PathMerchant;
import com.sgb.link.router.PathTeam;
import com.sgb.member.ui.activity.MemberAuditActivity;
import com.sgb.member.ui.activity.MemberInviteOrApplyActivity;
import com.sgb.member.ui.activity.MemberManageActivity;
import com.sgb.zhaocai.view.demand.activity.DemandForecastActivity;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.event.EventConstant;
import com.swgk.core.mmkvutil.CacheMarker;
import com.swgk.core.mmkvutil.DatalUtils;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.util.ACAdminDialogUtils;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.entity.MenuEntity;
import com.swgk.core.xrecyclerview.XRecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

import static com.sgb.kjwl.utils.NumberConstant.TEAM_CONSTRUCTION;
import static com.swgk.core.util.ACAdminDialogUtils.MK_OURINQUIRYPRICELIST;

/**
 * 需求大厅tab页签数据列表页
 * 这需求
 */
public class DemandHallListFragment2 extends AppFragment implements QuickEntryClickListener {

    private static final String DEMAND_TYPE = "demand_type";
    private String goosType;
    private FragmentDemandhallList2Binding binding;
    List<EnquiryTypeEntity> enquirylist = new ArrayList<>();
    List<EnquiryTypeEntity> sortlist = new ArrayList<>();
    List<EnquiryTypeEntity> userlist = new ArrayList<>();
    private String selectType;
    private String enquiryid = "0";
    private String userid = "";
    private String sortid = "2";
    private boolean isLoadMore = false;
    private int state;
    private int page = 1;
    @Inject
    DemandHallTabModel2 demandhalltabmodel;
    private Enquirytypepopwindow enquirytypepopwindow;
    private Enquirytypepopwindow userTypepopwindow;
    private Enquirytypepopwindow sortTypepopwindow;
    private DemandHallAdapter demandHallAdapter;
    private String searchName = "";
    private String tabName = "全部";
    private boolean isCreate = false;
    private boolean init = true;
    private boolean isVisible;
    private String tabNames;
    private String shoppingNo;
    private static int whereFrom = 0;
    String shareTitle = "";


    private QuickEntryPopWindow quickEntryPopWindow; //快捷入口弹框
    private List<MenuEntity> titleData = new ArrayList<>();
    private List<MenuEntity<MenuEntity<MenuEntity>>> mMaterialData = new ArrayList<>();


    public static DemandHallListFragment2 newInstance(String goodsType, int fromWhere) {
        whereFrom = fromWhere;
        DemandHallListFragment2 fragment = new DemandHallListFragment2();
        Bundle args = new Bundle();
        args.putString(DEMAND_TYPE, goodsType);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void setupFragmentComponent(AppComponent appComponent) {
        DaggerHomeFragComponent.builder()
                .appComponent(appComponent)
                .homeFragModule(new HomeFragModule(this))
                .build()
                .inject(this);
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        isVisible = isVisibleToUser;
        if (!isCreate) {
            return;
        }
        if (isVisibleToUser) {
            if (init) {
                init = false;
                if (getArguments() != null) {
                    goosType = getArguments().getString(DEMAND_TYPE);
                }
                tabName = goosType;
                initdata();
            }
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isCreate = true;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_demandhall_list2, container, false);
        binding.setViewModel(demandhalltabmodel);
        return binding.getRoot();
    }

    private void initdata() {
        demandhalltabmodel.getEnquiryType();
        demandhalltabmodel.getUserType();
        demandhalltabmodel.getSortType();
        getdata();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initview();
        if (init && isVisible) {
            if (!EventBus.getDefault().isRegistered(this)) {
                EventBus.getDefault().register(this);
            }
            if (getArguments() != null) {
                goosType = getArguments().getString(DEMAND_TYPE);
            }
            initdata();
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(LeaseEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_SELECT_DEMANDHALL_TAB) {
            tabNames = (String) event.getMessageData();
        }
        if (event.getMessageTag() == EventConstant.EVENT_SELECT_DEMANDHALL) {
            searchName = (String) event.getMessageData();
        }
        tabName = tabNames;
        getdata();
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEvent(LoginEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_SHOPPING_LIST_LOGIN) {
            SharedPreferenceUtil.getInstance().saveString("EVENT_SHOPPING_TYPE", "");
            demandhalltabmodel.showUrl(shoppingNo, shareTitle);
        }
    }

    private void initview() {

        binding.llStatus.setOnClickListener(this);
        binding.llUser.setOnClickListener(this);
        binding.llRank.setOnClickListener(this);
        binding.llArea.setOnClickListener(this);
        binding.llDistance.setOnClickListener(this);
        binding.demandpublish.setOnClickListener(this);
        binding.demandlocation.setOnClickListener(this);
        binding.imgBackTop.setOnClickListener(this);
        binding.ivQuickEntry.setOnClickListener(this);
        enquirytypepopwindow = new Enquirytypepopwindow(getActivity());
        enquirytypepopwindow.setBgView(binding.bgPopGrayLayout);
        userTypepopwindow = new Enquirytypepopwindow(getActivity());
        userTypepopwindow.setBgView(binding.bgPopGrayLayout);
        sortTypepopwindow = new Enquirytypepopwindow(getActivity());
        sortTypepopwindow.setBgView(binding.bgPopGrayLayout);
        if (whereFrom == 1) {
            binding.selectLayout.setVisibility(View.GONE);
        }
        enquirytypepopwindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                if (null != key1) {
                    enquiryid = ((EnquiryTypeEntity) key1).getId();
                    binding.tvStatus.setText(((EnquiryTypeEntity) key1).getName());
                    binding.tvStatus.setTextColor(ColorUtils.getColor(R.color.color_main));
                    binding.ivStatus.setImageDrawable(getActivity().getResources().getDrawable(com.swgk.core.R.mipmap.icon_down_red));
                    binding.llStatus.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                }
                getdata();
            }
        });
        userTypepopwindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                if (null != key1) {
                    userid = ((EnquiryTypeEntity) key1).getId();
                    binding.tvUser.setText(((EnquiryTypeEntity) key1).getName());
                    binding.tvUser.setTextColor(ColorUtils.getColor(R.color.color_main));
                    binding.ivUser.setImageDrawable(getActivity().getResources().getDrawable(com.swgk.core.R.mipmap.icon_down_red));
                    binding.llUser.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                }
                getdata();
            }
        });
        sortTypepopwindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                if (null != key1) {
                    sortid = ((EnquiryTypeEntity) key1).getId();
                    binding.tvRank.setText(((EnquiryTypeEntity) key1).getName());
                    binding.tvRank.setTextColor(ColorUtils.getColor(R.color.color_main));
                    binding.ivRank.setImageDrawable(getActivity().getResources().getDrawable(com.swgk.core.R.mipmap.icon_down_red));
                    binding.llRank.setBackground(ContextCompat.getDrawable(requireActivity(), R.drawable.search_new_blue_bg));
                }
                getdata();
            }
        });
        demandHallAdapter = new DemandHallAdapter(getActivity(), null);
        LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
        binding.demandList.setLayoutManager(layoutManager);
        binding.demandList.setAdapter(demandHallAdapter);
        binding.demandList.setLoadingMoreEnabled(true);
        binding.demandList.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                getdata();
            }

            @Override
            public void onLoadMore() {
                isLoadMore = true;
                page = page + 1;
                demandhalltabmodel.getDemandHallList(userid, sortid, enquiryid, tabName, searchName, page);
            }
        });

        demandHallAdapter.setOnItemClick(new AdapterOnItemClick<DemandHallListEntity>() {
            @Override
            public void onItemClick(DemandHallListEntity demandhalllistentity, int position) {
                shoppingNo = demandhalllistentity.getEnquiryNo();
                shareTitle = demandhalllistentity.getItemName();
//                跳转详情
                demandhalltabmodel.showUrl(demandhalllistentity.getEnquiryNo(), shareTitle);
            }
        });

        binding.demandList.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                Log.e("newstate:", newState + "");
            }

            @Override
            public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                Log.e("position:", layoutManager.findFirstVisibleItemPosition() + "");
                if (layoutManager.findFirstVisibleItemPosition() > 1) {
                    binding.imgBackTop.setVisibility(View.VISIBLE);
                } else {
                    binding.imgBackTop.setVisibility(View.GONE);
                }
            }
        });

    }

    private void getdata() {
        isLoadMore = false;
        page = 1;
        demandhalltabmodel.getDemandHallList(userid, sortid, enquiryid, tabName, searchName, page);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_status://状态选择
                if (null == enquirylist || enquirylist.size() == 0)
                    return;
                enquirytypepopwindow.showPopwindow(binding.selectLayout, 0, 0);
                enquirytypepopwindow.setData(enquirylist);
                break;
            case R.id.ll_user://用户选择
                if (null == userlist || userlist.size() == 0)
                    return;
                userTypepopwindow.showPopwindow(binding.selectLayout, 0, 0);
                userTypepopwindow.setData(userlist);
                break;
            case R.id.ll_area://地区选择
                break;
            case R.id.ll_distance://距离选择
                break;
            case R.id.ll_rank://排序选择
                if (null == sortlist || sortlist.size() == 0)
                    return;
                sortTypepopwindow.showPopwindow(binding.selectLayout, 0, 0);
                sortTypepopwindow.setData(sortlist);
                break;
            case R.id.demandpublish://需求大厅发布
                goLogin(getActivity());
                break;
            case R.id.demandlocation://需求大厅定位
                Intent intent = new Intent();
                intent.setClass(getActivity(), SelectAddressActivity.class);
                intent.putExtra(SelectAddressActivity.TITLE, "选择区域");
                intent.putExtra(SelectAddressActivity.HINT, "请输入你的定位地址");
                intent.putExtra(SelectAddressActivity.SAVE_TEXT, "使用该定位地址");
                intent.putExtra(SelectAddressActivity.CITY, "");
                startActivityForResult(intent, 999);
                break;
            case R.id.img_back_top:
                binding.demandList.smoothScrollToPosition(0);
                break;

            case R.id.iv_quick_entry:

                if (quickEntryPopWindow == null) {
                    quickEntryPopWindow = new QuickEntryPopWindow(getActivity());
                    //必须调用
                    quickEntryPopWindow.setListener(this::onItemClick);
                }
                quickEntryPopWindow.backgroundAlpha(0.5f);
                quickEntryPopWindow.setRecover();
                quickEntryPopWindow.showPopwindowLeft(binding.ivQuickEntry);


        }
    }

    public void goLogin(Context context) {
        int type = ACAdminDialogUtils.isPermissionForAsk(MK_OURINQUIRYPRICELIST, false);
        if (type == ACAdminDialogUtils.TYPE_NORMAL) {
            /*Intent createGood = new Intent(context, NewPurchasesActivity.class);
            createGood.putExtra("GOOD_EDIT", false);
            createGood.putExtra("GOOD_ADD", false);
            createGood.putExtra("GOOD_ENTITY", new GoodsItemEntity());
            startActivity(createGood);*/
            Intent createGoods = new Intent(context, InquiryPublishingActivity.class);
            context.startActivity(createGoods);
        } else {
            ACAdminDialogUtils.showACDialogForGoods(type, context);
        }
    }

    //返回状态数据
    public void getEnquirtTypeList(List<EnquiryTypeEntity> enquiryTypelist) {
        enquirylist.clear();
        enquirylist.addAll(enquiryTypelist);
    }

    //返回用户数据
    public void getUserTypeList(List<EnquiryTypeEntity> userTypelist) {
        userlist.clear();
        userlist.addAll(userTypelist);
    }

    //返回排序数据
    public void getSortTypeList(List<EnquiryTypeEntity> sortTypelist) {
        sortlist.clear();
        sortlist.addAll(sortTypelist);
    }

    //获取列表数据
    public void setDemandHallList(List<DemandHallListEntity> demandHallListEntityList) {
        binding.demandList.refreshComplete();
        if (isLoadMore) {
            binding.demandList.loadMoreComplete();
            if (demandHallListEntityList.size() > 0) {
                demandHallAdapter.addDatas(demandHallListEntityList);
            } else {
                binding.demandList.setLoadingMoreEnabled(false);
            }
            binding.demandList.setVisibility(View.VISIBLE);
        } else {
            binding.demandList.refreshComplete();
            if (demandHallListEntityList.size() > 0) {
                binding.demandList.setVisibility(View.VISIBLE);
                binding.emptyView.setVisibility(View.GONE);
                demandHallAdapter.setDatas(demandHallListEntityList);
                binding.demandList.setLoadingMoreEnabled(true);
            } else {
                demandHallAdapter.setDatas(null);
                binding.demandList.setVisibility(View.GONE);
                binding.emptyView.setVisibility(View.VISIBLE);
            }
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == 0 && resultCode == 1) {
            state = data.getIntExtra("state", -1);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }


    @Override
    public void onItemClick(QuickEntryEntity entity) {
        changeTabFragmentEvent(entity.getId());
        switch (entity.getId()) {
            case "0": //首页/网站推荐
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 21));
                break;
            case "1": //商品/销售
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 1));
                break;
            case "1-1": //全部商品
                if (titleData == null) {
                    demandhalltabmodel.recommendMenu(0, false);
                } else {
                    showImageButtonData(titleData, 0, false);
                }
                break;
            case "1-2": //自营商品
                if (titleData == null) {
                    demandhalltabmodel.recommendMenu(1, false);
                } else {
                    showImageButtonData(titleData, 1, false);
                }
                break;
            case "1-3": //集采商品
                if (titleData == null) {
                    demandhalltabmodel.recommendMenu(2, false);
                } else {
                    showImageButtonData(titleData, 2, false);
                }
                break;
            case "1-4": //促销商品
                if (titleData == null) {
                    demandhalltabmodel.recommendMenu(3, false);
                } else {
                    showImageButtonData(titleData, 3, false);
                }
                break;
            case "1-5": //供应商
                if (titleData == null) {
                    demandhalltabmodel.recommendMenu(5, false);
                } else {
                    showImageButtonData(titleData, 5, false);
                }
                break;
            case "2": //招标竞价
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 2));
                break;
            case "2-1": //招标大厅
                PickListActivity.start(getActivity(), "1", 0);
                break;
            case "2-2": //招标公告
                PickListActivity.start(getActivity(), "2", 0);
                break;
            case "2-3": //直接竞价
                PickBiddingListActivity.start(getActivity());
                break;
            case "2-4": //需求预告
                DemandForecastActivity.start(getActivity());
                break;
            case "2-5": //招标预告
                PickNoticeActivity.start(getActivity());
                break;
            case "2-6": //中标公告
                PickWinningNoticeActivity.start(getActivity());
                break;
            case "3": //集采团购
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 3));
                break;
            case "3-1": //集采大厅
                JiCaiDaTingActivity.start(getActivity());
                break;
            case "3-2": //需方发起
                XuFangFaQiActivity.start(getActivity(), "1");
                break;
            case "3-3": //供方发起
                FactoryCentralizedActivity.start(getActivity());
                break;
            case "3-4": //企业专项
                XuFangFaQiActivity.start(getActivity(), "2");
                break;
            case "3-5": //我的加盟
                if (!TextUtils.isEmpty(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    MyCenterMyJoinActivity.start(getActivity());
                } else {
                    VerificationCodeLoginActivity.start(getActivity());
                }
                break;
            case "3-6": //我的报价
                if (!TextUtils.isEmpty(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    JcMyPriceActivity.start(getActivity());
                } else {
                    VerificationCodeLoginActivity.start(getActivity());
                }
                break;
            case "4": //租赁转让
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 4));
                break;
            case "4-1": //出租大厅
                LeaseHallActivity2.start(getActivity());
                break;
            case "4-2": //需求大厅
                LeaseHallActivity2.start(getActivity(), 1, 0);
                break;
            case "5": //工队工人
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 5));
                break;
            case "5-1": //临时用工
                //临时用工-工队首页点击用工需求
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 0));
                break;
            case "5-2": //找工人
                //找工人-工队首页点击个人大厅
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 1));
                break;
            case "5-3": //施工队
                //施工队，班组工队，劳务公司-工队首页点击工队大厅 {"施工队", "班组工队", "劳务公司", "记工记账"};
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 2));
                break;
            case "5-4": //班组工队
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 2), Pair.create("childPosition", 1));
                break;
            case "5-5": //工程公司
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 5));
                break;
            case "5-6": //劳务公司 -工队首页点击工队大厅
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,
                        Pair.create("type", 2), Pair.create("childPosition", 2));
                break;
            case "5-7": //工种报价
                //"用工需求","工人大厅","工队大厅","工种报价","工程分包","工程公司","人气工队"
                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity, Pair.create("type", 3));
                break;
            case "6": //物流货运
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 6));
                break;
            case "6-1": //货运大厅
                GoodsCarsActivity.start(getActivity(), 0, false);
                break;
            case "6-2": //货车大厅
                GoodsCarsActivity.start(getActivity(), 1, true);
                break;
            case "6-3": //竞价货运
                BiddingTransportHallActivity.start(getContext());
                break;
            case "6-4": //竞价承运
                DriverLookForGoodsActivity.start(getContext());
                break;
            case "7": //企业服务
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
                break;
            case "7-1": //服务大厅
                ProfessionalQuoteActivity.start(getActivity());
                break;
            case "7-2": //需求大厅
                NeedActivity.start(getActivity());
                break;
            case "7-3": //知产交易
                ActivityJump.jumpToActivity(getActivity(), MakeOverActivity.class);
                break;
            case "7-4": //专业团队
                ActivityJump.jumpToActivity(getActivity(), ProfessionalTeamChangeActivity.class);
                break;
            case "8": //会员经营
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 24));
                break;
            case "8-1": //会员管理
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberManageActivity.start(getActivity());
                }
                break;
            case "8-2": //邀请会员
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 0);
                }
                break;
            case "8-3": //申请加盟
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 1);
                }
                break;
            case "8-4": //会员审核
                if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                    VerificationCodeLoginActivity.start(getActivity());
                } else {
                    MemberAuditActivity.start(getActivity());
                }
                break;
            case "9": //企业经营
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 23));
                break;
            case "9-1": //经营大厅
                String longitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LONGITUDE_ID, "");
                String latitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LATITUDE_ID, "");
                ActivityJump.jumpToActivity(getActivity(), ManageActivity.class, Pair.create("latitude", latitude), Pair.create("longitude", longitude));
                break;
            case "9-2": //专项资质
                SpecialQualificationActivity.startAction(getActivity());
                break;
            case "9-3": //知识产权
                IPActivity.startAction(getActivity());
                break;
            case "9-4": //专项资产
                EpAssestActivity.start(getActivity());
                break;
            case "9-5": //荣誉荣耀
                TradeHonorActivity.start(getActivity());
                break;
            case "9-6": //经营动态
                ActivityJump.jumpToActivity(getActivity(), CompanyTradesActivity.class);
                break;
            case "10": //招商引资
                EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 27));
                break;
            case "10-1": //投资项目
                ARouter.getInstance().build(PathMerchant.InvestmentProjectActivity).navigation();
                break;
            case "10-2": //投资需求
                ARouter.getInstance().build(PathMerchant.DemandListActivity).navigation();
                break;
        }
        //关闭弹框
        if (quickEntryPopWindow != null) {
            quickEntryPopWindow.dismiss();
        }
    }

    private void changeTabFragmentEvent(String id) {
        if (!TextUtils.isEmpty(id) && id.contains("-")) {
            int newId = Integer.parseInt(id.substring(0, id.indexOf("-")));
            switch (newId) {
                case 1:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 1));
                    break;
                case 2:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 2));
                    break;
                case 3:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 3));
                    break;
                case 4:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 4));
                    break;
                case 5:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 5));
                    break;
                case 6:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 6));
                    break;
                case 7:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 22));
                    break;
                case 8:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 24));
                    break;
                case 9:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 23));
                    break;
                case 10:
                    EventBus.getDefault().postSticky(CategoryEvent2.make(EventConstant.EVENT_CATEGORY_CHOOSE2, 27));
                    break;
            }
        }
    }

    public void showImageButtonData(List<MenuEntity> datas, int position, boolean isMap) {
        EventBus.getDefault().post(new UpdateIndexEvent(position, getActivity() instanceof GoodsAggregateActivity));
        getActivity().finish();
    }


    @SuppressLint({"AutoDispose", "CheckResult"})
    public void showRecommendCate(List<HomeMenuEntity> data, boolean isRefresh) {
    }
}
